﻿using System.Drawing;
using Microsoft.VisualStudio.DebuggerVisualizers;

namespace ColorVisualizer
{
    class ColorVisualizer : DialogDebuggerVisualizer
    {
        public ColorVisualizer() : base(FormatterPolicy.NewtonsoftJson)
        {

        }
        public ColorVisualizer(FormatterPolicy preferredFormatterPolicy) : base(preferredFormatterPolicy)
        {
        }

        protected override void Show(IDialogVisualizerService windowService, IVisualizerObjectProvider objectProvider)
        {
            IVisualizerObjectProvider3 objectProvider3 = objectProvider as IVisualizerObjectProvider3;
            Color? color = objectProvider3?.GetObject<Color>();

            if(color != null)
            {
                using(ColorForm form = new ColorForm())
                {
                    form.ShowInTaskbar = false;
                    form.Set(color.Value);

                    windowService.ShowDialog(form);
                }
            }
        }
    }
}